<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="java.util.Iterator"%>
<%@page import="com.xhd.vo.Fruits"%>
<%@page import="java.util.List"%>
<%@page import="com.xhd.Dao.SalerDaoImpl"%>
<%@page import="com.xhd.Dao.SalerDao"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<% 
	SalerDao sd = new SalerDaoImpl();
	List<Fruits> fruitlist=sd.haveFruitOrNot("待售");
	List<Fruits> fruitlist2=sd.haveFruitOrNot("被冻结");
	Iterator<Fruits> fIter=fruitlist.iterator();
	Iterator<Fruits> fIter2=fruitlist2.iterator();
	int left=0;
	int right=0;
	if (!fIter.hasNext()&&!fIter2.hasNext()){
	%>	
	商品已售罄，请上架商品后再试<br>
	<%	
	}
	else {
	%>
	<table border="1" width="100%" cellspacing="0" background="black">
	<tr bgcolor="rgb(78,78,78)" bordercolor="rgb(78,78,78)" align="center" style="color: white;">
	
			<td>水果图片</td>
			<td>水果名</td>
			<td>价格</td>
			<td>商品描述</td>
			<td></td>
	
	</tr>
	<%
		Fruits fruit=null;
		while(fIter.hasNext()){
		fruit=fIter.next();
	%>
	<tr bordercolor="rgb(78,78,78)" align="center">
	<td>
	<%
	left = 0;
	right = fruit.getFruit_picture().indexOf("@");
	while(right!=-1) {
		String imagepath = fruit.getFruit_picture().substring(left,right);
		//System.out.println("1:"+imagepath);
		%>
		<img style="height:100px; weight:100px;" src="./upload/<%=imagepath %>">
		<%
		left=right+1;
		right=fruit.getFruit_picture().indexOf("@",right+1);
		}
		String imagepath = fruit.getFruit_picture().substring(left,fruit.getFruit_picture().length());
		//System.out.println("2:"+imagepath);
		%>
		<img style="height:100px; weight:100px;" src="./upload/<%=imagepath %>"></td>
		<td><%=fruit.getFruit_name() %></td>
		<td><%=fruit.getFruit_price()%></td>
		<td><%=fruit.getFruit_describe()%></td>
		<td>
		<a href="FreezeFruitSuccess.jsp?name=<%=fruit.getFruit_name() %>">冻结商品</a>
		</td>
	</tr>
		<%
		}
	%>
	<%
		Fruits fruit2=null;
		while(fIter2.hasNext()){
		fruit2=fIter2.next();
	%>
	<tr bordercolor="rgb(78,78,78)" align="center">
	<td>
		<%
		left = 0;
		right = fruit2.getFruit_picture().indexOf("@");
		while(right!=-1) {
			String imagepath = fruit2.getFruit_picture().substring(left,right);
			//System.out.println("1:"+imagepath);
			%>
			<img style="height:100px; weight:100px;" src="./upload/<%=imagepath %>">
			<%
			left=right+1;
			right=fruit2.getFruit_picture().indexOf("@",right+1);
		}
		String imagepath = fruit2.getFruit_picture().substring(left,fruit2.getFruit_picture().length());
		//System.out.println("2:"+imagepath);
		%>
		<img style="height:100px; weight:100px;" src="./upload/<%=imagepath %>"></td>
		<td><%=fruit2.getFruit_name() %></td>
		<td><%=fruit2.getFruit_price()%></td>
		<td><%=fruit2.getFruit_describe()%></td>
		<td>
		<a href="ThawFruit.jsp?name=<%=fruit2.getFruit_name() %>">解冻商品</a>
		</td>
	</tr>
		<%
		}
	%>
</table>
<%} %>
</body>
</html>